Skip to content

Add simple API sample for VK_EXT_present_timing.#1535

Open
nvlduc wants to merge 3 commits intoKhronosGroup:mainfrom
nvlduc:present_timing_api
Open

Add simple API sample for VK_EXT_present_timing.#1535
nvlduc wants to merge 3 commits intoKhronosGroup:mainfrom
nvlduc:present_timing_api

Conversation

@nvlduc
Copy link
Copy Markdown

@nvlduc nvlduc commented Apr 29, 2026

Description

This change adds a new "API" sample demonstrating usage of the VK_EXT_present_timing API. I chose this type of sample as opposed to a more complex demo to focus on the API design of this particular extension, rather than exploring the problem space of frame pacing and swapchain best practices which require interactions with other unrelated extensions.

The simple rendering (a circle moving across the display) is a decent test to verify the quality of a VK_EXT_present_timing implementation.

I unfortunately do not have equipment to build this on macOS or Android.

This sample was tested using latest NVIDIA beta developer drivers on Windows 11 (596.10) and Linux (595.44.05) with an NVIDIA RTX 4080.

General Checklist:

Please ensure the following points are checked:

  • My code follows the coding style
  • I have reviewed file licenses
  • I have commented any added functions (in line with Doxygen)
  • I have commented any code that could be hard to understand
  • My changes do not add any new compiler warnings
  • My changes do not add any new validation layer errors or warnings
  • I have used existing framework/helper functions where possible
  • My changes do not add any regressions
  • I have tested every sample to ensure everything runs correctly
  • This PR describes the scope and expected impact of the changes I am making

Note: The Samples CI runs a number of checks including:

  • I have updated the header Copyright to reflect the current year (CI build will fail if Copyright is out of date)
  • My changes build on Windows, Linux, macOS and Android. Otherwise I have documented any exceptions
    • I have not tested on macOS / Android.

If this PR contains framework changes:

  • I did a full batch run using the batch command line argument to make sure all samples still work properly

Sample Checklist

If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist:

  • I have tested the sample on at least one compliant Vulkan implementation
  • If the sample is vendor-specific, I have tagged it appropriately
  • I have stated on what implementation the sample has been tested so that others can test on different implementations and platforms
  • Any dependent assets have been merged and published in downstream modules
  • For new samples, I have added a paragraph with a summary to the appropriate chapter in the readme of the folder that the sample belongs to e.g. api samples readme
  • For new samples, I have added a tutorial README.md file to guide users through what they need to know to implement code using this feature. For example, see conditional_rendering
  • For new samples, I have added a link to the Antora navigation so that the sample will be listed at the Vulkan documentation site

Copy link
Copy Markdown
Contributor

@asuessenbach asuessenbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting sample!
Unfortunately, it doesn't run on my environment (Win11, NVIDIA RTX A3000 Laptop GPU). It gets a VK_ERROR_SURFACE_LOST_KHR on vkQueuePresentKHR after vkGetPastPresentationTimingEXT got more than 0 (1, to be precise) past_presentation_properties.presentationTimingCount for the first time.
Any idea what that might mean?

Besides that, I have a couple of questions...

Comment thread samples/api/swapchain_present_timing/README.adoc
Comment thread samples/api/swapchain_present_timing/README.adoc
Comment thread samples/api/swapchain_present_timing/README.adoc Outdated
Comment thread samples/api/swapchain_present_timing/swapchain_present_timing.cpp Outdated
Comment thread samples/api/swapchain_present_timing/swapchain_present_timing.cpp
Comment thread samples/api/swapchain_present_timing/swapchain_present_timing.cpp
Comment thread samples/api/swapchain_present_timing/swapchain_present_timing.cpp
Comment thread samples/api/swapchain_present_timing/swapchain_present_timing.cpp Outdated
Comment thread samples/api/swapchain_present_timing/swapchain_present_timing.cpp Outdated
std::array<VkPastPresentationTimingEXT, history_buffer_size> past_presentation_timings;

/// Frame timing history. This is not directly used and is meant as an example.
std::array<FrameTimingData, history_buffer_size> timing_history;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need past_presentation_timings and timing_history to be the same size, or can they be sized differently?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They can be different, I probably got lazy here and re-used a constant. I'll add it in the comment

nvlduc added 2 commits May 5, 2026 11:46
- Fix "times domains" typo in README
- Add missing blank lines before bullet lists in README
- Rename desired_swapchain_images to desired_swapchain_image_count
- Simplify can_use_present_timing boolean assignment
@nvlduc
Copy link
Copy Markdown
Author

nvlduc commented May 5, 2026

Thank you for the review @asuessenbach

Unfortunately, it doesn't run on my environment (Win11, NVIDIA RTX A3000 Laptop GPU). It gets a VK_ERROR_SURFACE_LOST_KHR on vkQueuePresentKHR after vkGetPastPresentationTimingEXT got more than 0 (1, to be precise) past_presentation_properties.presentationTimingCount for the first time.
Any idea what that might mean?

Oh, I have not tested this with an igpu, though I don't see how this app could generate a surface lost error. Looking at our implementation, it's also very unexpected. I'll see if I can get my hands on a similar system and look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants